<?php
$section = 'user';
$titre = _LB_ACCOUNT_MANAGEMENT;
$smarty->assign("titre", $titre);

//get object ID
$id = Request::getIntNumber('id');
$act = Request::getIntNumber('act');

//get back link
$backlink = Session::getBackLink($section,"list/?");

$user = new Login();
if($id <= 0 || !$user->get($id))
{
	redirect($backlink);
}

//if action = UPDATE or CREATE
if ($act == ACT_VALID_EDIT)
{
	if ($user->validateChangePassInput())
	{
        $user->PASSWORD = sha1(Request::get("PASS"));
        $user->update();
		redirect($backlink);
	}

}

//create cfer
$cfer = new Cfer(array(
	_LB_ACCUEIL => Utils::getHomeLink(),
	_LB_ACCOUNT_MANAGEMENT => $backlink,
	($id == 0? _LB_ADD_ACCOUNT : _LB_EDIT_ACCOUNT) => Utils::getCurrentLink() ));

//if validate is false, display form again
$smarty->assign('cfer', $cfer);
$smarty->assign('user', $user);
$smarty->assign('backlink', $backlink);
$smarty->display('user_change_pass.html');